const jwt = require("jsonwebtoken");

const TOKEN_TIME = 5; // token过期时间 (秒)
const REFRESHTOKEN_TIME = 1000; // 刷新token过期时间 (秒)
const SECRET = "secret"; // 密钥

const generatorToken = () => {
  let token = jwt.sign({}, SECRET, {
    expiresIn: TOKEN_TIME,
  });
  let refreshToken = jwt.sign({}, SECRET, {
    expiresIn: REFRESHTOKEN_TIME,
  });

  return {
    token,
    refreshToken,
  };
};

module.exports = {
  generatorToken,
  SECRET,
};
